package spotGUI.floatingChatGUI;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import spotGUI.utils.EmptyContentAreaButton;

public class SendFilePanel extends JPanel implements SendFileFeedback {
	
	private JLabel lblInfo;
	private JButton btnHide;
	
	private JProgressBar progressBar;


	public SendFilePanel() {
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{16, 21, 0};
		gridBagLayout.rowHeights = new int[]{22, 22, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);

		btnHide = new EmptyContentAreaButton(ReceiveFilePanel.class.getResource("/images/Icons/16x16px/delete.png"), "");
		btnHide.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		GridBagConstraints gbc_btnHide = new GridBagConstraints();
		gbc_btnHide.anchor = GridBagConstraints.WEST;
		gbc_btnHide.fill = GridBagConstraints.VERTICAL;
		gbc_btnHide.insets = new Insets(0, 0, 5, 5);
		gbc_btnHide.gridx = 0;
		gbc_btnHide.gridy = 0;
		add(btnHide, gbc_btnHide);

		lblInfo = new JLabel("");
		GridBagConstraints gbc_lblInfo = new GridBagConstraints();
		gbc_lblInfo.fill = GridBagConstraints.BOTH;
		gbc_lblInfo.insets = new Insets(0, 0, 5, 0);
		gbc_lblInfo.gridx = 1;
		gbc_lblInfo.gridy = 0;
		add(lblInfo, gbc_lblInfo);
		
		progressBar = new JProgressBar();
		progressBar.setStringPainted(true);
		progressBar.setVisible(false);
		progressBar.setIndeterminate(true);
		progressBar.setOpaque(false);
		progressBar.setString("");
		GridBagConstraints gbc_progressBar = new GridBagConstraints();
		gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
		gbc_progressBar.gridx = 1;
		gbc_progressBar.gridy = 1;
		add(progressBar, gbc_progressBar);
		
		setVisible(false);
	}
	
	public void updateLogBar (String text, ImageIcon icon) {
		lblInfo.setText(text);
		lblInfo.setIcon(icon);
	}

	
	public void lock (boolean lock) {
		btnHide.setEnabled(!lock);
	}
	
	

	public void setSending (boolean sending) {
		progressBar.setVisible(sending);
	}
}
